package io.renren.modules.sys.service.impl;

import io.renren.modules.sys.entity.ShelvesOrdersEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.TakeoutsetDao;
import io.renren.modules.sys.entity.TakeoutsetEntity;
import io.renren.modules.sys.entity.TakeoutEntity;
import io.renren.modules.sys.service.TakeoutsetService;


@Service("takeoutsetService")
public class TakeoutsetServiceImpl extends ServiceImpl<TakeoutsetDao, TakeoutsetEntity> implements TakeoutsetService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        IPage<TakeoutsetEntity> page = this.page(
                new Query<TakeoutsetEntity>().getPage(params),
                new QueryWrapper<TakeoutsetEntity>()
        );

        return new PageUtils(page);
    }


    @Override
    public PageUtils getTakeOut(Map<String, Object> params){

        int pageSize = Integer.parseInt(params.get("limit").toString());  //每页记录数
        int currPage = Integer.parseInt(params.get("page").toString());  //当前页数

        String name = null;
        if(params.get("name")!=null&&!params.get("name").equals("")){
            name = params.get("name").toString();
        }

        Integer statu = null;
        if( params.get("statu")!=null&&!params.get("statu").equals("")){
            statu = Integer.parseInt(params.get("statu").toString());
        }



        int count = baseMapper.queryListcount(name,statu);
        List<TakeoutEntity> list = baseMapper.getTakeOut(name,statu,(currPage-1)*pageSize,currPage*pageSize);

        return new PageUtils(list,count,pageSize,currPage);
    }

}
